import Toast from "react-native-root-toast";
import {ifIphoneX} from 'react-native-iphone-x-helper'
import {ToastAndroid, Platform} from "react-native";
const ToastUtil = {
  show: function (message, duration) {
    if (message && message.length > 0) {
      if (Platform.OS === 'ios') {
        Toast.show(message, {
          duration: Toast.durations.SHORT,
          position: (ifIphoneX ? -100 : Toast.positions.BOTTOM)
        });
      }
      else {
        ToastAndroid.show(message, ToastAndroid.SHORT);
      }
    }
  },
  showCenter: function(message) {
    if (message && message.length > 0) {
      if (Platform.OS === 'ios') {
        Toast.show(message, {
          duration: Toast.durations.SHORT,
          position: Toast.positions.CENTER
        });
      }
      else {
        ToastAndroid.showWithGravity(message, ToastAndroid.SHORT, ToastAndroid.CENTER);
      }
    }
  },
  showWithOptions: function (message, options) {
    if (message && message.length > 0) {
      if (Platform.OS === 'ios') {
        Toast.show(message, {
          duration: Toast.durations.SHORT,
          position: (ifIphoneX ? -100 : Toast.positions.BOTTOM),
          ...options
        });
      }
      else {
        ToastAndroid.show(message, ToastAndroid.SHORT);
      }
    }
  }
};
export default ToastUtil;
